using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Autions;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Autions
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOAutions_Select_All action = new BOAutions_Select_All();
                usp_Autions_Select_All entity = new usp_Autions_Select_All();
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOAutions_Select_Top action = new BOAutions_Select_Top();
                usp_Autions_Select_Top entity = new usp_Autions_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int aution_id)
        {
            try
            {
                BOAutions_Search action = new BOAutions_Search();
                usp_Autions_Search entity = new usp_Autions_Search();
                entity.AUTION_ID = aution_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOAutions_Select_WithPaged action = new BOAutions_Select_WithPaged();
                usp_Autions_Select_WithPaged entity = new usp_Autions_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(Int64 product_id, DateTime start_date, DateTime end_date, decimal start_price, decimal step_price, decimal current_price, DateTime last_bid, Int64 last_user_bid, int total_bid, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOAutions_Insert action = new BOAutions_Insert();
                usp_Autions_Insert entity = new usp_Autions_Insert();
                entity.PRODUCT_ID = product_id;
                entity.START_DATE = start_date;
                entity.END_DATE = end_date;
                entity.START_PRICE = start_price;
                entity.STEP_PRICE = step_price;
                entity.CURRENT_PRICE = current_price;
                entity.LAST_BID = last_bid;
                entity.LAST_USER_BID = last_user_bid;
                entity.TOTAL_BID = total_bid;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 aution_id, Int64 product_id, DateTime start_date, DateTime end_date, decimal start_price, decimal step_price, decimal current_price, DateTime last_bid, Int64 last_user_bid, int total_bid, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOAutions_Update action = new BOAutions_Update();
                usp_Autions_Update entity = new usp_Autions_Update();
                entity.AUTION_ID = aution_id;
                entity.PRODUCT_ID = product_id;
                entity.START_DATE = start_date;
                entity.END_DATE = end_date;
                entity.START_PRICE = start_price;
                entity.STEP_PRICE = step_price;
                entity.CURRENT_PRICE = current_price;
                entity.LAST_BID = last_bid;
                entity.LAST_USER_BID = last_user_bid;
                entity.TOTAL_BID = total_bid;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int aution_id)
        {
            try
            {
                BOAutions_Delete action = new BOAutions_Delete();
                usp_Autions_Delete entity = new usp_Autions_Delete();
                entity.AUTION_ID = aution_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int aution_id)
        {
            try
            {
                BOAutions_Restore action = new BOAutions_Restore();
                usp_Autions_Restore entity = new usp_Autions_Restore();
                entity.AUTION_ID = aution_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByModule(int status, int startindex, int maxrecord, int module_id)
        {
            try
            {
                BOAutions_Select_By_Module action = new BOAutions_Select_By_Module();
                usp_Autions_Select_By_Module entity = new usp_Autions_Select_By_Module();
                entity.MAXRECORDS = maxrecord;
                entity.MODULE_ID = module_id;
                entity.STARTINDEX = startindex;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Order(int mid, string list_aid_order)
        {
            try
            {
                BOAutions_Order action = new BOAutions_Order();
                usp_Autions_Order entity = new usp_Autions_Order();
                entity.MID = mid;
                entity.LIST_AID_ORDER = list_aid_order;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchByProduct(int product_id)
        {
            try
            {
                BOAutions_Search_By_Product action = new BOAutions_Search_By_Product();
                usp_Autions_Search_By_Product entity = new usp_Autions_Search_By_Product();
                entity.PRODUCT_ID = product_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

